package springmvc.param.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * description: 06
 * TODO：获取请求头
 *
 * Host                    localhost:8080
 * Accept                  text/html,application/xhtml+xml,application/xml;q=0.9
 * Accept-Language         fr,en-gb;q=0.7,en;q=0.3
 * Accept-Encoding         gzip,deflate
 * Accept-Charset          ISO-8859-1,utf-8;q=0.7,*;q=0.7
 * Keep-Alive              300
 *
 * 1. @RequestHeader("Host") 接收请求头参数
 */

@Controller
@RequestMapping("header")
@ResponseBody
public class HeaderController {

    @GetMapping("data")
    public String data(@RequestHeader("Host") String host,
                       @RequestHeader("Accept-Encoding") String encoding,
                       @RequestHeader("Connection") String connection){
        System.out.println("Host = " + host + ", Accept-Encoding = " + encoding + ", Connection = " + connection);
        return "Host = " + host + ", Accept-Encoding = " + encoding + ", Connection = " + connection;
        // Host = localhost:8080, Accept-Encoding = gzip, deflate, br, Connection = keep-alive
    }
}
